/*
 * @Author: Kang
 * @Date: 2021-11-29 09:32:22
 * @Last Modified by: Kang
 * @LastEditTime: 2022-06-28 21:21:38
 */
'use strict';
const moment = require('moment');
const { v4: uuidv4 } = require('uuid');

module.exports = {
  formatTime(date, format = 'YYYY-MM-DD') {
    return moment(date).format(format);
  },
  getUUID() {
    return uuidv4();
  },
  randomInt() {
    let chars = '0123456789';
    /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
    let maxPos = chars.length;
    let code = '';
    for (let i = 0; i < 6; i++) {
      code += chars.charAt(Math.floor(Math.random() * maxPos));
    }
    return code;
  },
  successRes(data = [], msg = '操作成功！', code = 200) {
    return { data, msg, code }
  }
};
